package test.example.com.yuapi;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ImageView;
import android.widget.Toast;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.callback.StringCallback;

import butterknife.BindView;
import butterknife.ButterKnife;
import okhttp3.Call;
import okhttp3.Response;

public class MainActivity extends AppCompatActivity {


    @BindView(R.id.imageView)
    ImageView imageView;
    private String DOMAIN = "http://wmhty.com/";
    private String token = "";
    private String login_userid = "";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ButterKnife.bind(this);
        Glide.with(this)
                .load("http://img3.yxlady.com/yl/UploadFiles_5361/20151031/20151031163054784.jpg")
                .error(R.mipmap.ic_launcher)
                .into(imageView);

    }

    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.test:  //测试网络 出现图片网络正常
                test();
                Glide.with(this)
                        .load("http://img3.yxlady.com/yl/UploadFiles_5361/20151031/20151031163054784.jpg")
                        .error(R.mipmap.ic_launcher)
                        .into(imageView);
                break;
            case R.id.button1:  //登录
                method1();
                break;
            case R.id.button2:  //登出
                method2();
                break;
            case R.id.button3:  //添加个人信息
                method3();
                break;
            case R.id.button4:  //修改账户基本信息
                method4();
                break;
            case R.id.button5:  //修改用户密码
                method5();
                break;
            case R.id.button6:  //修改备用密码
                method6();
                break;
            case R.id.button7:  //修改用户头像
                method7();
                break;
            case R.id.button8:  //修改身份证图片
                method8();
                break;
            case R.id.button9:  //删除用户
                method9();
                break;
            case R.id.button10:  //获取单个用户信息
                method10();
                break;
            case R.id.button11:  //获取登录用户信息
                method11();
                break;
            case R.id.button12:  //获取用户列表
                method12();
                break;
            case R.id.button13:  //添加商品
                method13();
                break;
            case R.id.button14:  //修改商品
                method14();
                break;
            case R.id.button15:  //更新商品图片
                method15();
                break;
            case R.id.button16:  //修改商品属性
                method16();
                break;
            case R.id.button17:  //删除商品
                method17();
                break;
            case R.id.button18:  //获取单个商品数据
                method18();
                break;
            case R.id.button19:  //获取商品列表
                method19();
                break;
            case R.id.button20:  //获取随机商品列表
                method20();
                break;
            case R.id.button21:  //获取系统推荐商品列表
                method21();
                break;
            case R.id.button22:  //用户行为记录
                method22();
                break;
            case R.id.button23:  //获取所有权限名称列表
                method23();
                break;
            case R.id.button24:  //获取所有分类类型列表
                method24();
                break;
            case R.id.button25:  //根据类型ID获取分类列表
                method25();
                break;
            case R.id.button26:  //文件上传接口
                method26();
                break;
            case R.id.button27:  //添加评论
                method27();
                break;
            case R.id.button28:  //删除评论
                method28();
                break;
            case R.id.button29:  //获取评论列表
                method29();
                break;
            case R.id.button30:  //添加权限类型
                method30();
                break;
            case R.id.button31:  //添加权限类型列表
                method31();
                break;
            case R.id.button32:  //添加权限
                method32();
                break;
            case R.id.button33:  //修改权限名称
                method33();
                break;
            case R.id.button34:  //根据类型获取权限列表
                method34();
                break;
            case R.id.button35:  //更新用户等级权限
                method35();
                break;
            case R.id.button36:  //添加用户等级
                method36();
                break;
            case R.id.button37:  //修改用户等级
                method37();
                break;
            case R.id.button38:  //获取用户等级所以列表
                method38();
                break;


        }

    }
    private void test(){
        OkGo.get("")
                .execute(new StringCallback() {
                    @Override
                    public void onSuccess(String s, Call call, Response response) {

                    }
                });
    }

    //登录
    private void method1() {
        OkGo.post(DOMAIN + "api.ashx?action=login")     //接口地址
                .params("username", "请输入账号")      //账号
                .params("passwrod", "请输入密码")      //密码
                .execute(new StringCallback() {
                    @Override
                    public void onSuccess(String s, Call call, Response response) {
                        Toast.makeText(MainActivity.this, "登录返回" + s, Toast.LENGTH_SHORT).show();
                        //生成token 赋值给全局变量
                        token = "生成的token";
                        login_userid = "生成的id";
                    }
                });


    }

    //登出
    private void method2() {
        OkGo.post(DOMAIN + "api.ashx?action=logout")           //接口地址
                .params("login_userid", login_userid)         //id
                .params("login_token", token)                 //用户凭证
                .execute(new StringCallback() {
                    @Override
                    public void onSuccess(String s, Call call, Response response) {
                        Toast.makeText(MainActivity.this, "登出返回" + s, Toast.LENGTH_SHORT).show();

                    }
                });
    }

    //添加用户
    private void method3() {
        OkGo.post(DOMAIN + "Api.ashx?action=adduser")          //接口地址
                .params("login_userid", login_userid)          //id
                .params("login_token", token)                  //用户凭证
                .params("accountname","用户id")                //用户账户名称，即用户ID
                .params("Password","用户账户密码")             //用户账户密码
                .params("passwordsec","用户备用账户密码")      //用户备用账户密码
                .params("qq","QQ")                             //QQ
                .params("email","email")                       //邮箱
                .params("mobile","手机号")                     //手机号
                .params("addressanc","祖籍地址")               //祖籍地址
                .execute(new StringCallback() {
                    @Override
                    public void onSuccess(String s, Call call, Response response) {
                        Toast.makeText(MainActivity.this, "添加用户返回" + s, Toast.LENGTH_SHORT).show();


                    }
                });
    }

    //修改账户基本信息
    private void method4() {
        OkGo.post(DOMAIN + "Api.ashx?action= updateuser")           //接口地址
                .params("login_userid", login_userid)         //id
                .params("login_token", token)                 //用户凭证
                .execute(new StringCallback() {
                    @Override
                    public void onSuccess(String s, Call call, Response response) {
                        Toast.makeText(MainActivity.this, "登出返回" + s, Toast.LENGTH_SHORT).show();


                    }
                });
    }

    //修改用户密码
    private void method5() {
        OkGo.post(DOMAIN + "Api.ashx?action=updateuserpwd")           //接口地址
                .params("login_userid", login_userid)         //id
                .params("login_token", token)                 //用户凭证
                .params("id", "要修改的id")                  //要修改的用户编号。
                .execute(new StringCallback() {
                    @Override
                    public void onSuccess(String s, Call call, Response response) {
                        Toast.makeText(MainActivity.this, "修改用户密码返回" + s, Toast.LENGTH_SHORT).show();


                    }
                });
    }

    //修改备用密码
    private void method6() {
        OkGo.post(DOMAIN + "Api.ashx?action=updateusersecpwd")           //接口地址
                .params("login_userid", login_userid)                    //id
                .params("id", "要修改的用户编号")                        //要修改的用户编号
                .execute(new StringCallback() {
                    @Override
                    public void onSuccess(String s, Call call, Response response) {
                        Toast.makeText(MainActivity.this, "修改备用密码返回" + s, Toast.LENGTH_SHORT).show();

                    }
                });
    }

    //修改用户头像
    private void method7() {
        OkGo.post(DOMAIN + "Api.ashx?action=updateuseravatar")           //接口地址
                .params("login_userid", login_userid)         //id
                .params("login_token", token)                 //用户凭证
                .execute(new StringCallback() {
                    @Override
                    public void onSuccess(String s, Call call, Response response) {
                        Toast.makeText(MainActivity.this, "登出返回" + s, Toast.LENGTH_SHORT).show();


                    }
                });
    }

    //修改身份证图片
    private void method8() {
        OkGo.post(DOMAIN + "api.ashx?action=logout")           //接口地址
                .params("login_userid", login_userid)         //id
                .params("login_token", token)                 //用户凭证
                .execute(new StringCallback() {
                    @Override
                    public void onSuccess(String s, Call call, Response response) {
                        Toast.makeText(MainActivity.this, "登出返回" + s, Toast.LENGTH_SHORT).show();


                    }
                });
    }

    //删除用户
    private void method9() {
        OkGo.post(DOMAIN + "api.ashx?action=logout")           //接口地址
                .params("login_userid", login_userid)         //id
                .params("login_token", token)                 //用户凭证
                .execute(new StringCallback() {
                    @Override
                    public void onSuccess(String s, Call call, Response response) {
                        Toast.makeText(MainActivity.this, "登出返回" + s, Toast.LENGTH_SHORT).show();


                    }
                });
    }

    //获取单个用户信息
    private void method10() {
        OkGo.post(DOMAIN + "api.ashx?action=logout")           //接口地址
                .params("login_userid", login_userid)         //id
                .params("login_token", token)                 //用户凭证
                .execute(new StringCallback() {
                    @Override
                    public void onSuccess(String s, Call call, Response response) {
                        Toast.makeText(MainActivity.this, "登出返回" + s, Toast.LENGTH_SHORT).show();


                    }
                });
    }

    //获取登录用户信息
    private void method11() {
        OkGo.post(DOMAIN + "api.ashx?action=logout")           //接口地址
                .params("login_userid", login_userid)         //id
                .params("login_token", token)                 //用户凭证
                .execute(new StringCallback() {
                    @Override
                    public void onSuccess(String s, Call call, Response response) {
                        Toast.makeText(MainActivity.this, "登出返回" + s, Toast.LENGTH_SHORT).show();


                    }
                });
    }

    //获取用户列表
    private void method12() {
        OkGo.post(DOMAIN + "api.ashx?action=logout")           //接口地址
                .params("login_userid", login_userid)         //id
                .params("login_token", token)                 //用户凭证
                .execute(new StringCallback() {
                    @Override
                    public void onSuccess(String s, Call call, Response response) {
                        Toast.makeText(MainActivity.this, "登出返回" + s, Toast.LENGTH_SHORT).show();


                    }
                });
    }

    //添加商品
    private void method13() {
        OkGo.post(DOMAIN + "api.ashx?action=logout")           //接口地址
                .params("login_userid", login_userid)         //id
                .params("login_token", token)                 //用户凭证
                .execute(new StringCallback() {
                    @Override
                    public void onSuccess(String s, Call call, Response response) {
                        Toast.makeText(MainActivity.this, "登出返回" + s, Toast.LENGTH_SHORT).show();


                    }
                });
    }

    //修改商品
    private void method14() {
        OkGo.post(DOMAIN + "api.ashx?action=logout")           //接口地址
                .params("login_userid", login_userid)         //id
                .params("login_token", token)                 //用户凭证
                .execute(new StringCallback() {
                    @Override
                    public void onSuccess(String s, Call call, Response response) {
                        Toast.makeText(MainActivity.this, "登出返回" + s, Toast.LENGTH_SHORT).show();


                    }
                });
    }

    //更新商品图片
    private void method15() {
        OkGo.post(DOMAIN + "api.ashx?action=logout")           //接口地址
                .params("login_userid", login_userid)         //id
                .params("login_token", token)                 //用户凭证
                .execute(new StringCallback() {
                    @Override
                    public void onSuccess(String s, Call call, Response response) {
                        Toast.makeText(MainActivity.this, "登出返回" + s, Toast.LENGTH_SHORT).show();


                    }
                });
    }

    //修改商品属性
    private void method16() {
        OkGo.post(DOMAIN + "api.ashx?action=logout")           //接口地址
                .params("login_userid", login_userid)         //id
                .params("login_token", token)                 //用户凭证
                .execute(new StringCallback() {
                    @Override
                    public void onSuccess(String s, Call call, Response response) {
                        Toast.makeText(MainActivity.this, "登出返回" + s, Toast.LENGTH_SHORT).show();


                    }
                });
    }

    //删除商品
    private void method17() {
        OkGo.post(DOMAIN + "api.ashx?action=logout")           //接口地址
                .params("login_userid", login_userid)         //id
                .params("login_token", token)                 //用户凭证
                .execute(new StringCallback() {
                    @Override
                    public void onSuccess(String s, Call call, Response response) {
                        Toast.makeText(MainActivity.this, "登出返回" + s, Toast.LENGTH_SHORT).show();


                    }
                });
    }

    //获取单个商品数据
    private void method18() {
        OkGo.post(DOMAIN + "api.ashx?action=logout")           //接口地址
                .params("login_userid", login_userid)         //id
                .params("login_token", token)                 //用户凭证
                .execute(new StringCallback() {
                    @Override
                    public void onSuccess(String s, Call call, Response response) {
                        Toast.makeText(MainActivity.this, "登出返回" + s, Toast.LENGTH_SHORT).show();


                    }
                });
    }

    //获取商品列表
    private void method19() {
        OkGo.post(DOMAIN + "api.ashx?action=logout")           //接口地址
                .params("login_userid", login_userid)         //id
                .params("login_token", token)                 //用户凭证
                .execute(new StringCallback() {
                    @Override
                    public void onSuccess(String s, Call call, Response response) {
                        Toast.makeText(MainActivity.this, "登出返回" + s, Toast.LENGTH_SHORT).show();


                    }
                });
    }

    //获取随机商品列表
    private void method20() {
        OkGo.post(DOMAIN + "api.ashx?action=logout")           //接口地址
                .params("login_userid", login_userid)         //id
                .params("login_token", token)                 //用户凭证
                .execute(new StringCallback() {
                    @Override
                    public void onSuccess(String s, Call call, Response response) {
                        Toast.makeText(MainActivity.this, "登出返回" + s, Toast.LENGTH_SHORT).show();


                    }
                });
    }

    //获取系统推荐商品列表
    private void method21() {
        OkGo.post(DOMAIN + "api.ashx?action=logout")           //接口地址
                .params("login_userid", login_userid)         //id
                .params("login_token", token)                 //用户凭证
                .execute(new StringCallback() {
                    @Override
                    public void onSuccess(String s, Call call, Response response) {
                        Toast.makeText(MainActivity.this, "登出返回" + s, Toast.LENGTH_SHORT).show();


                    }
                });
    }

    //用户行为记录
    private void method22() {
        OkGo.post(DOMAIN + "api.ashx?action=logout")           //接口地址
                .params("login_userid", login_userid)         //id
                .params("login_token", token)                 //用户凭证
                .execute(new StringCallback() {
                    @Override
                    public void onSuccess(String s, Call call, Response response) {
                        Toast.makeText(MainActivity.this, "登出返回" + s, Toast.LENGTH_SHORT).show();


                    }
                });
    }

    //获取所有权限名称列表
    private void method23() {
        OkGo.post(DOMAIN + "api.ashx?action=logout")           //接口地址
                .params("login_userid", login_userid)         //id
                .params("login_token", token)                 //用户凭证
                .execute(new StringCallback() {
                    @Override
                    public void onSuccess(String s, Call call, Response response) {
                        Toast.makeText(MainActivity.this, "登出返回" + s, Toast.LENGTH_SHORT).show();


                    }
                });
    }

    //获取所有分类类型列表
    private void method24() {
        OkGo.post(DOMAIN + "api.ashx?action=logout")           //接口地址
                .params("login_userid", login_userid)         //id
                .params("login_token", token)                 //用户凭证
                .execute(new StringCallback() {
                    @Override
                    public void onSuccess(String s, Call call, Response response) {
                        Toast.makeText(MainActivity.this, "登出返回" + s, Toast.LENGTH_SHORT).show();


                    }
                });
    }

    //根据类型ID获取分类列表
    private void method25() {
        OkGo.post(DOMAIN + "api.ashx?action=logout")           //接口地址
                .params("login_userid", login_userid)         //id
                .params("login_token", token)                 //用户凭证
                .execute(new StringCallback() {
                    @Override
                    public void onSuccess(String s, Call call, Response response) {
                        Toast.makeText(MainActivity.this, "登出返回" + s, Toast.LENGTH_SHORT).show();


                    }
                });
    }

    //文件上传接口
    private void method26() {
        OkGo.post(DOMAIN + "api.ashx?action=logout")           //接口地址
                .params("login_userid", login_userid)         //id
                .params("login_token", token)                 //用户凭证
                .execute(new StringCallback() {
                    @Override
                    public void onSuccess(String s, Call call, Response response) {
                        Toast.makeText(MainActivity.this, "登出返回" + s, Toast.LENGTH_SHORT).show();


                    }
                });
    }

    //添加评论
    private void method27() {
        OkGo.post(DOMAIN + "api.ashx?action=logout")           //接口地址
                .params("login_userid", login_userid)         //id
                .params("login_token", token)                 //用户凭证
                .execute(new StringCallback() {
                    @Override
                    public void onSuccess(String s, Call call, Response response) {
                        Toast.makeText(MainActivity.this, "登出返回" + s, Toast.LENGTH_SHORT).show();


                    }
                });
    }

    //删除评论
    private void method28() {
        OkGo.post(DOMAIN + "api.ashx?action=logout")           //接口地址
                .params("login_userid", login_userid)         //id
                .params("login_token", token)                 //用户凭证
                .execute(new StringCallback() {
                    @Override
                    public void onSuccess(String s, Call call, Response response) {
                        Toast.makeText(MainActivity.this, "登出返回" + s, Toast.LENGTH_SHORT).show();


                    }
                });
    }

    //获取评论列表
    private void method29() {
        OkGo.post(DOMAIN + "api.ashx?action=logout")           //接口地址
                .params("login_userid", login_userid)         //id
                .params("login_token", token)                 //用户凭证
                .execute(new StringCallback() {
                    @Override
                    public void onSuccess(String s, Call call, Response response) {
                        Toast.makeText(MainActivity.this, "登出返回" + s, Toast.LENGTH_SHORT).show();


                    }
                });
    }

    //添加权限类型
    private void method30() {
        OkGo.post(DOMAIN + "api.ashx?action=logout")           //接口地址
                .params("login_userid", login_userid)         //id
                .params("login_token", token)                 //用户凭证
                .execute(new StringCallback() {
                    @Override
                    public void onSuccess(String s, Call call, Response response) {
                        Toast.makeText(MainActivity.this, "登出返回" + s, Toast.LENGTH_SHORT).show();


                    }
                });
    }

    //添加权限类型列表
    private void method31() {
        OkGo.post(DOMAIN + "api.ashx?action=logout")           //接口地址
                .params("login_userid", login_userid)         //id
                .params("login_token", token)                 //用户凭证
                .execute(new StringCallback() {
                    @Override
                    public void onSuccess(String s, Call call, Response response) {
                        Toast.makeText(MainActivity.this, "登出返回" + s, Toast.LENGTH_SHORT).show();


                    }
                });
    }

    //添加权限
    private void method32() {
        OkGo.post(DOMAIN + "api.ashx?action=logout")           //接口地址
                .params("login_userid", login_userid)         //id
                .params("login_token", token)                 //用户凭证
                .execute(new StringCallback() {
                    @Override
                    public void onSuccess(String s, Call call, Response response) {
                        Toast.makeText(MainActivity.this, "登出返回" + s, Toast.LENGTH_SHORT).show();


                    }
                });
    }

    //修改权限名称
    private void method33() {
        OkGo.post(DOMAIN + "api.ashx?action=logout")           //接口地址
                .params("login_userid", login_userid)         //id
                .params("login_token", token)                 //用户凭证
                .execute(new StringCallback() {
                    @Override
                    public void onSuccess(String s, Call call, Response response) {
                        Toast.makeText(MainActivity.this, "登出返回" + s, Toast.LENGTH_SHORT).show();


                    }
                });
    }

    //根据类型获取权限列表
    private void method34() {
        OkGo.post(DOMAIN + "api.ashx?action=logout")           //接口地址
                .params("login_userid", login_userid)         //id
                .params("login_token", token)                 //用户凭证
                .execute(new StringCallback() {
                    @Override
                    public void onSuccess(String s, Call call, Response response) {
                        Toast.makeText(MainActivity.this, "登出返回" + s, Toast.LENGTH_SHORT).show();


                    }
                });
    }

    //更新用户等级权限
    private void method35() {
        OkGo.post(DOMAIN + "api.ashx?action=logout")           //接口地址
                .params("login_userid", login_userid)         //id
                .params("login_token", token)                 //用户凭证
                .execute(new StringCallback() {
                    @Override
                    public void onSuccess(String s, Call call, Response response) {
                        Toast.makeText(MainActivity.this, "登出返回" + s, Toast.LENGTH_SHORT).show();


                    }
                });
    }

    //添加用户等级
    private void method36() {
        OkGo.post(DOMAIN + "api.ashx?action=logout")           //接口地址
                .params("login_userid", login_userid)         //id
                .params("login_token", token)                 //用户凭证
                .execute(new StringCallback() {
                    @Override
                    public void onSuccess(String s, Call call, Response response) {
                        Toast.makeText(MainActivity.this, "登出返回" + s, Toast.LENGTH_SHORT).show();


                    }
                });
    }

    //修改用户等级
    private void method37() {
        OkGo.post(DOMAIN + "api.ashx?action=logout")           //接口地址
                .params("login_userid", login_userid)         //id
                .params("login_token", token)                 //用户凭证
                .execute(new StringCallback() {
                    @Override
                    public void onSuccess(String s, Call call, Response response) {
                        Toast.makeText(MainActivity.this, "登出返回" + s, Toast.LENGTH_SHORT).show();


                    }
                });
    }

    //获取用户等级所以列表
    private void method38() {
        OkGo.post(DOMAIN + "api.ashx?action=logout")           //接口地址
                .params("login_userid", login_userid)         //id
                .params("login_token", token)                 //用户凭证
                .execute(new StringCallback() {
                    @Override
                    public void onSuccess(String s, Call call, Response response) {
                        Toast.makeText(MainActivity.this, "登出返回" + s, Toast.LENGTH_SHORT).show();


                    }
                });
    }


}
